package com.t17;

import java.util.HashMap;
import java.util.Map;

import static net.mindview.util.Print.print;
import static net.mindview.util.Print.printnb;

/**
 * Created by xuyiwei on 2018/8/15.
 */
public class Maps {
    public static void printKeys(Map<Integer,String> map){
        printnb("Size = "+map.size()+". ");
        printnb("Keys: ");
        print(map.keySet());
    }
    public static void test(Map<Integer,String> map){
        print(map.getClass().getSimpleName());
        map.putAll(new CountingMapData(25));
        System.out.println(map.values());
        printKeys(map);
        printnb("Values: ");
        print(map.values());
        print(map);
        print("map.containsKey(11):"+map.containsKey(11));
        print("map.get(11):"+map.get(11));
        print("map.containsValue(11):"+map.containsValue(11));
        Integer key = map.keySet().iterator().next();
        print("First key in map: "+key);
        map.remove(key);
        map.clear();
        print("map.isEmpty(): "+map.isEmpty());
        map.putAll(new CountingMapData(25));
        map.keySet().removeAll(map.keySet());
        print("map.isEmpty(): "+map.isEmpty());
    }

    public static void main(String[] args) {
        test(new HashMap<>());
        /**HashMap
         [A0, B0, C0, D0, E0, F0, G0, H0, I0, J0, K0, L0, M0, N0, O0, P0, Q0, R0, S0, T0, U0, V0, W0, X0, Y0]
         Size = 25. Keys: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]
         Values: [A0, B0, C0, D0, E0, F0, G0, H0, I0, J0, K0, L0, M0, N0, O0, P0, Q0, R0, S0, T0, U0, V0, W0, X0, Y0]
         {0=A0, 1=B0, 2=C0, 3=D0, 4=E0, 5=F0, 6=G0, 7=H0, 8=I0, 9=J0, 10=K0, 11=L0, 12=M0, 13=N0, 14=O0, 15=P0, 16=Q0, 17=R0, 18=S0, 19=T0, 20=U0, 21=V0, 22=W0, 23=X0, 24=Y0}
         map.containsKey(11):true
         map.get(11):L0
         map.containsValue(11):false
         First key in map: 0
         map.isEmpty(): true
         map.isEmpty(): true
         */
    }
}
